<include file="Public:header" />
<!--主体内容-->
<!--左边-->
<div class="centent_box">
    <include file="Public:left" />
    <!--右边-->
    <div class="centent_right_box">
        <div class="centent_right rightCon">
            <div class="Mtitle">
                <ul>
                    <li class="on"><span>成交管理</span></li>
                </ul>
                <div class="rightWord"><a href="{:U('Deal/index')}">成交管理</a> &gt;&gt; 开始成交</div>
            </div>
            <form id="info_form" action="{:U('Deal/add')}" method="post" enctype="multipart/form-data">
                <div class="used-centent">
                    <ul class="formList width2 list_ul list_mp">
                        <li>
                            <label>房源名字：</label>
                            <input type="text"  name="data[title]" value="{$info.title}" id="title" class="inputStyle" style="width:250px" readonly>
                            <!--label>房源编码：</label>
                            <input type="text" class="inputStyle" name="data[encoded]" value="{$info.encoded}" style="width:250px" readonly-->
                            <label>交易类型：</label>
                            <input type="text" class="inputStyle" name="data[encoded]" value="<if condition='$info.sell_type eq 1'>出售<else/>出租</if>" style="width:50px" readonly>
                            <input type="hidden"  name="data[used_id]" value="{$info.id}">
                            <input type="hidden"  name="data[sell_type]" value="{$info.sell_type}">
                            <input type="hidden"  name="data[deal_id]" value="{$info.deal_id}">
                        </li>
                        <li class="dict-info">
                            <label>卖方/业主：</label>
                            <input type="text" class="inputStyle width2" name="data[proprietor]" value="{$info.proprietor}" >
                            <label>联系方式：</label>
                            <input type="text" class="inputStyle width2" name="data[p_phone]" value="{$info.p_phone}" >
                            <label>证件号码：</label>
                            <input type="text" class="inputStyle" style="width:250px" name="data[p_card]" value="{$info.p_card}">
                        </li>
                        <li class="dict-info">
                            <label>买方/客户：</label>
                            <input type="text" class="inputStyle width2" name="data[customer]" value="{$info.customer}" id="customs" placeholder="输入后可以匹配客源">
                            <input type="hidden" name="data[average_price]" id="custid">
                            <label>联系方式：</label>
                            <input type="text" class="inputStyle width2" name="data[c_phone]" id="c-phone" value="{$info.c_phone}">
                            <label>证件号码：</label>
                            <input type="text" class="inputStyle" style="width:250px" id="c-card" name="data[c_card]" value="{$info.c_card}">
                        </li>
                        <li class="dict-info">
                            <label>成交价格：</label>
                            <input type="text" class="inputStyle width2" name="data[money]" value="{$info.money}">
                            <label>佣金总额：</label>
                            <input type="text" class="inputStyle width2" name="data[poundage]" value="{$info.poundage}">
                            <label>成交日期：</label>
                            <input type="text" class="inputStyle" style="width:250px" name="data[deal_time]" onclick="laydate()" value="{$info.deal_time|substr=###,0,10}">
                        </li>
                        <li class="dict-info">
                            <label>佣金扣除：</label>
                            <input type="text" class="inputStyle width2" name="data[deduct]" value="{$info.deduct}">
                            <label>已收佣金：</label>
                            <input type="text" class="inputStyle width2" name="data[received]" value="{$info.received}">
                            <label>佣金备注：</label>
                            <input type="text" class="inputStyle" style="width:250px" name="data[diary]" value="{$info.diary}">
                        </li>
                        <li>
                            <label>合同备注：</label>
                            <input type="text"  name="data[remark]" class="inputStyle width3" value="{$info.remark}">
                        </li>
                        <li id="files">
                            <label>图片上传：</label>
                            <script id="uploadpic" name="uploadpic" type="text/plain"></script>
                            <input type="button" class="btn btn_submit" style="margin:0 0 10px 10px;" onclick="upImage();" value="选择图片">
                            <div id="imageList">
                                <ul class="list clearfix"></ul>
                            </div>
                            <input type="hidden" name="file" id="file" />
                        </li>
                        <li>
                            <label></label>
                            <input type="submit" value="提 交" class="btnStyle">
                        </li>
                    </ul>
                </div>
            </form>

        </div>
    </div>
</div>
<js file="__S__/ueditor/ueditor.config.js" charset="utf-8" />
<js file="__S__/ueditor/ueditor.all.min.js" charset="utf-8" />
<js file="__S__/ueditor/lang/zh-cn/zh-cn.js" charset="utf-8" />
<js file="__JS__/uploadImg.js" charset="utf-8" />
<script type="text/javascript">
    window.UEDITOR_HOME_URL='__STATIC__/ueditor/';
    window.onload=function(){
        window.UEDITOR_CONFIG.initialFrameWidth=880;
        window.UEDITOR_CONFIG.initialFrameHeight=500;
        upmoreimg();
    }
    var ue = UE.getEditor('info', {
        toolbars: [[
            'fullscreen', 'source', '|',
            'bold', 'italic', 'underline', '|', 'fontfamily','fontsize', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', 'simpleupload','|', 'kityformula', 'preview'
        ]]
    });
</script>
<script src="__S__/js/jquery.validate.js"></script>
<script type="text/javascript">
    $(function(){
        $("#info_form").validate({
            rules: {
                "data[title]": {
                    required: true,
                    minlength: 2
                },
                "data[p_card]": {
                    required:true
                },
                "data[c_card]": {
                    required: true
                },
                "data[proprietor]": {
                    required: true
                },
                "data[c_phone]": {
                    required: true
                },
                "data[money]": {
                    required: true
                },
                "data[poundage]": {
                    required: true
                }
            },
            messages: {
                "data[title]": {
                    required: "请输入房源名称",
                    minlength: "房源名称一定要两个字以上"
                },
                "data[p_card]": {
                    required: "请输入业主证件号"
                },
                "data[c_card]": {
                    required: "请输入客户证件号"
                },
                "data[money]": {
                    required: "请填写房源总价"
                },
                "data[poundage]": {
                    required: "请填写佣金总额"
                }
            }
        });

        //所属地区
        $.validator.addMethod("area", function(value, element) {
            if($("#area_id").val()!=0){
                return true
            }else{
                return false
            }
        }, "请选择所属地区");
    });
    $('#customs').blur (function (){
        var name = $(this).val();console.log(name);
        if (name == '') return false;
        var url = "{:U('Cust/ajaxmach')}",data = {name:name};
        $.get (url, data, function (respose){
            if (respose.state == 'ok') {
                var html = '<div class="ajax-msg">';
                $.each(respose.data, function (i, v) {
                    html += '<div class="ajax-buttom" data-phone="'+v.contact+'" data-card="'+v.id_card+'" onclick="fill(this,' + v.id + ')">' +
                            '<button class="button">' + v.title + '</button>' +
                            '</div>';
                });
                html += '</div>';
                layer.open({
                    area: ['300px', '300px'],
                    type: 1,
                    content: html
                });
            }
        },'json');

    });
    function fill (tar,id){
        var phone = $(tar).attr('data-phone');console.log(phone);
        var card = $(tar).attr('data-card');console.log(card);
        var name = $(tar).children('button').html();console.log(name);
        $('#c-phone').val(phone);
        $('#c-card').val(card);
        $('#customs').val(name);
        $('#custid').val(id);
        layer.closeAll();

    }
</script>
<include file="Public:footer" />